package com.zsh.activities;

import com.zsh.constant.Constant;
import com.zsh.handler.SplashHandler;
import com.zsh.prototype.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class SplashActivity extends Activity {
	 
	boolean isFirstIn = false;

	private SplashHandler mHandler = new SplashHandler(this); 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		init();	
	}
	
	private void init() {
		int target;
		SharedPreferences preferences = getSharedPreferences(
				Constant.SHAREDPREFERENCES_NAME, MODE_PRIVATE);

		isFirstIn = preferences.getBoolean("isFirstIn", true);
		if (!isFirstIn) {
			target = Constant.GO_MAIN;
		} else {
			target = Constant.GO_FEATURES;
		}
		mHandler.sendEmptyMessageDelayed(target, Constant.SPLASH_DELAY_MILLIS);
	}	
	public void goMain() {
		Intent intent = new Intent(SplashActivity.this, MainActivity.class);
		SplashActivity.this.startActivity(intent);
		SplashActivity.this.finish();
	}

	public void goFeatures() {
		Intent intent = new Intent(SplashActivity.this, FeaturesActivity.class);
		SplashActivity.this.startActivity(intent);
		SplashActivity.this.finish();
	}
}
